#region File Description
//-----------------------------------------------------------------------------
// OptionsMenuScreen.cs
//
// Microsoft XNA Community Game Platform
// Copyright (C) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
#endregion

#region Using Statements
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
#endregion

namespace Alex_s_Dream_The_Toy_World
{
    /// <summary>
    /// The options screen is brought up over the top of the main menu
    /// screen, and gives the user a chance to configure the game
    /// in various hopefully useful ways.
    /// </summary>
    class HelpMenuScreen : MenuScreen
    {
        #region Fields
        MenuEntry languageMenuEntry;
        ContentManager content;
        Texture2D backgroundTexture;
        Texture2D[] toyWorld;
        KeyboardState keyState,PreKeyState;
        int state = 0;

        #endregion

        static string[] languages = { "C#", "XNA" };
        static int currentLanguage = 0;


        #region Initialization

        public override void LoadContent(ContentManager contentManager)
        {
            if (contentManager == null)
                content = new ContentManager(ScreenManager.Game.Services, "Content");
            else
                content = contentManager;

            backgroundTexture = content.Load<Texture2D>("Menu/" + "hatetoy");
            toyWorld = new Texture2D[7];
            toyWorld[0] = content.Load<Texture2D>("Menu/" + "hatetoy");
            toyWorld[1] = content.Load<Texture2D>("Menu/" + "toychess");
            toyWorld[2] = content.Load<Texture2D>("Menu/" + "mum");
            toyWorld[3] = content.Load<Texture2D>("Menu/" + "sleep");
            toyWorld[4] = content.Load<Texture2D>("Menu/" + "fairyworld");
            toyWorld[5] = content.Load<Texture2D>("Menu/" + "angel");
            toyWorld[6] = content.Load<Texture2D>("Menu/" + "angrytoy");
        }
        public override void Draw(GameTime gameTime)
        {
            PreKeyState = keyState; 
            keyState = Keyboard.GetState();
            SpriteBatch spriteBatch = ScreenManager.SpriteBatch;
            Viewport viewport = ScreenManager.Game.GraphicsDevice.Viewport;
            Rectangle fullscreen = new Rectangle(0, 0, viewport.Width, viewport.Height);
            byte fade = TransitionAlpha;

            spriteBatch.Begin(SpriteBlendMode.None);
            if (state < 6 && (keyState.IsKeyDown(Keys.Right) && PreKeyState.IsKeyUp(Keys.Right) || keyState.IsKeyDown(Keys.Down) && PreKeyState.IsKeyUp(Keys.Down)))
            {
                state++;
            }
            if (state > 0 && (keyState.IsKeyDown(Keys.Left) && PreKeyState.IsKeyUp(Keys.Left) || keyState.IsKeyDown(Keys.Up) && PreKeyState.IsKeyUp(Keys.Up)))
            {
                state--;
            }
            spriteBatch.Draw(toyWorld[state], fullscreen,new Color(fade, fade, fade));

            spriteBatch.End();
        }
        /// <summary>
        /// Constructor.
        /// </summary>
        public HelpMenuScreen()
            : base("Help")
        {
            languageMenuEntry = new MenuEntry(string.Empty);
            languageMenuEntry.Selected += LanguageMenuEntrySelected;
            MenuEntries.Add(languageMenuEntry);
        }
        void SetMenuEntryText()
        {
            languageMenuEntry.Text = "Language: " + languages[currentLanguage];
        }
        void LanguageMenuEntrySelected(object sender, EventArgs e)
        {
            currentLanguage = (currentLanguage + 1) % languages.Length;

            SetMenuEntryText();
        }

        #endregion
    }
}
